//
//  RemoveBindingView.m
//  Toyohu
//
//  Created by GuoPeng on 16/4/27.
//  Copyright © 2016年 celia. All rights reserved.
//

#import "RemoveBindingView.h"
#import "UIView+Fillet.h"
#import "BeingLiftedView.h"



typedef void (^SuccessBlock)(NSString *str);

@interface RemoveBindingView ()

@property (nonatomic, copy) SuccessBlock successBlock;

@property (weak, nonatomic) IBOutlet UIVisualEffectView *bgVEView;
@property (weak, nonatomic) IBOutlet UIButton *giveUpButton;
@property (weak, nonatomic) IBOutlet UIButton *determineButton;

@property (weak, nonatomic) IBOutlet UIView *bgView;

@property (nonatomic, strong) NSString *str;

@end

@implementation RemoveBindingView

+ (void)show
{
    
    

    [[[self alloc] init] initWithSuccessBlock:^(NSString *str) {
        [BeingLiftedView show];
    } frame:[[UIScreen mainScreen] bounds] ];
}

//- (instancetype)initWithFrame:(CGRect)frame
//{
//    [self initWithSuccessBlock:^(NSString *str) {
//        
//    } frame:[[UIScreen mainScreen] bounds]];
//}

- (instancetype)initWithSuccessBlock:(void (^)(NSString *str))successBlock frame:(CGRect)frame
{
    self = [[[NSBundle mainBundle] loadNibNamed:@"RemoveBindingView" owner:self options:nil] objectAtIndex:0];
    if (self) {
        self.frame = frame;

        [self initView];
        
        _successBlock = successBlock;
        [[[UIApplication sharedApplication] keyWindow] addSubview:self];
        
        
    }
    return self;
    
}

- (IBAction)giveUpClick:(id)sender
{
    [self removeFromSuperview];
    
}


- (IBAction)determineClick:(id)sender
{
    [self removeFromSuperview];
    
    
    if (self.successBlock) {
        self.successBlock(@"ok");
    }
}

- (void)initView{
    self.giveUpButton.clipsToBounds = YES;
    self.giveUpButton.layer.cornerRadius = self.giveUpButton.frame.size.height / 2;
    self.giveUpButton.layer.borderColor = [UIColor orangeColor].CGColor;
    self.giveUpButton.layer.borderWidth = 1.0f;
    
    self.determineButton.clipsToBounds = YES;
    self.determineButton.layer.cornerRadius = self.determineButton.frame.size.height / 2;
    self.determineButton.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.determineButton.layer.borderWidth = 1.0f;
    
    [self.bgView filletWithcornerRadius:8.0f];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
